<!DOCTYPE html>
<html>
<head>
    <title>userTask新增邮件设置</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" id="bpm_theme" type="text/css" href="../../easyui/newtheme/bule/devclient.css">
    <script type="text/javascript" src="../../jscode/lang/zh_CN.js"></script>
    <script type="text/javascript" src="../../easyui/jquery.min.js"></script>
    <script type="text/javascript" src="../../easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../../jscode/sharefunction.js"></script>
    <script type="text/javascript" src="../../jscode/json.js"></script>
    <script type="text/javascript" src="../../jscode/app_openform.js"></script>
    <script type="text/javascript" src="../../jscode/uivalidate.js"></script>
    <script type="text/javascript" src="../../jscode/app_custom.js"></script>
    <script>
        var WF_GoUrl = "../view/EmailSetting.html", WF_Appid = "S002",
            WF_DocUnid = "38cb67850b525045650ba6b040226d5a36ef";

        var CONFIG = [];
        $.ajax({
            url: "../config/config.json",
            //同步请求
            async: false,
            type: 'GET',
            success: function (data) {
                CONFIG = data;
            }
        });

        function formonload() {
            $('#WF_DocUnid').val(GetUrlArg("wf_docunid"));

            var mainConfGetUrl = CONFIG.url.getFlowChartMailConfigByUnid;
            mainConfGetUrl = mainConfGetUrl.replace("{unid}", GetUrlArg("wf_docunid"));

            if (GetUrlArg("wf_docunid")) {
                $.ajax({
                    async: false,
                    type: "GET",
                    url: mainConfGetUrl,
                    dataType: "json",
                    success: function (data) {
                        for (var key in data) {
                            if (key === 'CopyTo') {
                                $('#CopyTo').combobox('setValue', data[key]);
                            }
                            if (key === 'SendTo') {
                                $('#SendTo').combobox('setValue', data[key]);
                            }
                            if (key === 'Actionid') {
                                $('#Actionid').combobox('setValue', data[key]);
                            }
                            $('#' + key).val(data[key]);
                        }
                    }
                });
            }
        }

        function formonsubmit() {
            //return false to exit submit
        }

        function SaveDocument(btnAction) {
            var map = {};
            $("input").each(function () {
                var input = $(this);
                if (input.attr("id") !== undefined)
                    map[input.attr("id")] = input.val();
            });
            map['AllNodeEndStartFlag'] = $("input[name='AllNodeEndStartFlag']").prop("checked") ? "1" : "0";
            map['MailBody'] = $('#MailBody').val();
            map['Actionid'] = $('#Actionid').combobox('getValues').toString();
            map['SendTo'] = $('#SendTo').combobox('getValues').toString();
            map['CopyTo'] = $('#CopyTo').combobox('getValues').toString();
            map['WF_OrUnid'] = GetUrlArg("wf_docunid");
            var postData = {
                "json": JSON.stringify(map)
            }

            mask();
            $.post(CONFIG.url.saveFlowChartMailConfigByNodeType + "?Processid=" + GetUrlArg("Processid") + "&Nodeid=" + GetUrlArg("Nodeid") + "&ExtNodeType=" + GetUrlArg("ExtNodeType"),
                postData, function (data) {
                    backurl();
                });
        }

        function SaveDocumentCallBack(btnAction, rs) {
            //保存成功后的回调函数
            alert(rs.msg);
            WF_GoUrl += "?Processid=" + GetUrlArg("Processid") + "&Nodeid=" + GetUrlArg("Nodeid");
            if (btnAction == "Quit") {
                location.replace(WF_GoUrl);
            }
        }

        function backurl() {
            var url = "../view/EmailSetting.html?Processid=" + GetUrlArg("Processid") + "&Nodeid=" + GetUrlArg("Nodeid");
            location.href = url;
        }
    </script>
</head>
<body style="margin:2px 5px 5px 5px;" scroll="auto">
<form method="post" name="linkeyform" id="linkeyform">
    <table class="linkeytable">
        <tbody>
        <tr class="firstRow">
            <td width="58" align="right" valign="middle" style="-ms-word-break: break-all;">主送</td>
            <td valign="middle"><input
                    data-options="method:'GET',url:'../json/SendTo.json',valueField:'FieldValue',textField:'FieldText',multiple:true"
                    style="height:28px" name="SendTo" class="easyui-combobox" id="SendTo" size="65"
                    value="{WF_InNewUser}" exttype="combobox"/></td>
        </tr>
        <tr>
            <td align="right" valign="middle" style="-ms-word-break: break-all;">抄送</td>
            <td valign="middle"><input
                    data-options="method:'GET',url:'../json/SendTo.json',valueField:'FieldValue',textField:'FieldText'"
                    style="height:28px" name="CopyTo" class="easyui-combobox" id="CopyTo" size="65" value=""
                    exttype="combobox"/></td>
        </tr>
        <tr>
            <td align="right" valign="middle" style="-ms-word-break: break-all;">动作</td>
            <td valign="middle" style="-ms-word-break: break-all;"><input
                    data-options="method:'GET',url:'../json/Action.json',valueField:'Actionid',textField:'ActionName',method:'get'"
                    style="height:28px" name="Actionid" title="*表示所有" class="easyui-combobox" id="Actionid" size="65"
                    value="*" exttype="combobox"/>(*表示所有)
            </td>
        </tr>
        <tr>
            <td align="right" valign="middle" style="-ms-word-break: break-all;">标题</td>
            <td valign="middle"><input data-options="required:true" class="easyui-validatebox" name="MailTitle"
                                       id="MailTitle" style="width: 80%;" size="20" value="待办:{Subject}需要您进行处理!"/></td>
        </tr>
        <tr>
            <td align="right" valign="middle" style="-ms-word-break: break-all;">内容</td>
            <td valign="middle" style="-ms-word-break: break-all;"><textarea name="MailBody"
                                                                             title="{字段名}可获得文档中的字段{Userid}获得发件人{WF_InNewUser}新审批人{WF_AddName}申请人,{WF_EndUser}所有已审批人"
                                                                             id="MailBody"
                                                                             style="width: 80%; height: 200px;">
标题:{Subject} 
申请人:{WF_AddName}
申请时间:{WF_DocCreated}
流程:{WF_ProcessName}
打开链接:{DOCLINK}</textarea></td>
        </tr>
        <tr>
            <td valign="middle" style="-ms-word-break: break-all;" rowspan="1" colspan="1"></td>
            <td valign="middle" style="-ms-word-break: break-all;" rowspan="1" colspan="1"><a
                    data-options="iconCls:'icon-save',plain:false" onclick="SaveDocument(&quot;Quit&quot;)" name="btn0"
                    class="easyui-linkbutton" id="btn0" href="#" exttype="linkbutton">保存设置</a>&nbsp;<a
                    data-options="iconCls:'icon-undo',plain:false" onclick="backurl()" name="btn1"
                    class="easyui-linkbutton" id="btn1" href="#" exttype="linkbutton">返回</a></td>
        </tr>
        </tbody>
    </table>
    <p><input name="Processid" id="Processid" style="width: 80px; height: 21px;" type="hidden" size="1" value=""/><input
            name="Nodeid" id="Nodeid" style="width: 80px; height: 21px;" type="hidden" size="1" value="T00001"/></p>
    <!-- Hidden Field Begin-->
    <div style="display:none">
        <input name="WF_DocUnid" id="WF_DocUnid" value=""/>
        <input name="WF_FormNumber" id="WF_FormNumber" value="F_S002_A025"/>
        <input name="WF_UserName" id="WF_UserName" value="admin" disabled=""/>
        <input name="WF_Appid" id="WF_Appid" value="S002"/>
        <input name="WF_NewDocFlag" id="WF_NewDocFlag" value="true" disabled=""/>
        <!-- true表示新文档-->
        <input name="WF_ReadOnly" id="WF_ReadOnly" value="false" disabled=""/>
        <!-- true表示只读状态,false表示编辑状态-->
    </div>
    <!-- Hidden Field End-->
</form>
<div id="win"></div>
</body>
</html>